<template>
	<view class="normal-login-container">
		<view style="height: 100vh;">
			<view class="logo-content align-center justify-center flex">
				<text class="title">姜堰污水厂智慧水务管理平台</text>
			</view>
			<view class="login-form-content">
				<view style="display: flex;justify-content: center;font-weight: 700;font-size: 20px;">登录</view>
				<view class="input-item flex align-center">
					<view class="iconfont icon-user icon"></view>
					<input v-model="loginForm.username" class="input" type="text" placeholder="请输入账号" maxlength="30" />
				</view>
				<view class="input-item flex align-center" >
					<view class="iconfont icon-password icon"></view>
					<input v-model="loginForm.password" type="password" class="input" placeholder="请输入密码"
						maxlength="20" />
				</view>
				<view style="display: flex;justify-content: center;margin-top: 60rpx; ">
					<button @click="handleLogin" class="login-btn cu-btn block bg-blue lg round">登录</button>
				</view>


			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				// 用户注册开关
				register: false,
				globalConfig: getApp().globalData.config,
				// loginForm: {
				// 	username: "manage",
				// 	password: "Manage@2023_"
				// }
				loginForm: {
					username: "",
					password: ""
				}
			}
		},
		created() {},
		methods: {

			// 登录方法
			async handleLogin() {
				if (this.loginForm.username === "") {
					this.$modal.msgError("请输入您的账号")
				} else if (this.loginForm.password === "") {
					this.$modal.msgError("请输入您的密码")
				} else {
					this.$modal.loading("登录中，请耐心等待...")
					this.pwdLogin()
				}
			},
			// 密码登录
			async pwdLogin() {
				this.$store.dispatch('Login', this.loginForm).then(() => {
					this.$modal.closeLoading()
					this.loginSuccess()
				}).catch(() => {
					this.$modal.closeLoading()
				})
			},
			// 登录成功后，处理函数
			loginSuccess(result) {
				console.info('------',result)
				// 设置用户信息
				// this.$store.dispatch('GetInfo').then(res => {
				this.$tab.reLaunch('/pages/index')
				// })
			}
		}
	}
</script>

<style lang="scss">
	page {
		background-color: #ffffff;
	}

	.normal-login-container {

		background: url('../static/images/0421-03.png');

		background-repeat: no-repeat;
		background-position: top center;
		background-size: cover;

		.logo-content {
			width: 100%;
			font-size: 21px;
			text-align: center;
			padding-top: 15%;

			image {
				border-radius: 4px;
			}

			.title {
				margin-left: 10px;
				margin-top: 25%;
				font-size: 26px;
				color: #ffffff;
			}
		}

		.login-form-content {
			text-align: center;
			margin: 20px auto;
			height: 620rpx;

			margin-top: 17%;
			width: 90%;
			background-color: rgba(210, 225, 246, 0.7);
			border-radius: 14px;
			padding: 20px;
			padding-top: 30px;

			.input-item {
				margin: 20px auto;
				background-color: #fff;
				height: 55px;
				border-radius: 8px;

				.icon {
					font-size: 38rpx;
					margin-left: 10px;
					color: #999;
				}

				.input {
					width: 100%;
					font-size: 20px;
					line-height: 55px;
					text-align: left;
					padding-left: 15px;
				}

			}

			.login-btn {
				margin-top: 20rpx;
				height: 45px;
				border-radius: 8rpx;
				background-color: #5390E0;
				width: 80%;
				font-size: 20px;
			}






		}
	}
</style>